<template>
	<div class="ProcessManagement">
		<!-- 音频组件 -->
		<audio controls ref="audio" class="aud" v-show="false">
		  <source src="../../../../public/mp3/NO.mp3" />
		</audio>
		<audio controls ref="audioT" class="aud" v-show="false">
		  <source src="../../../../public/mp3/OK.mp3" />
		</audio>
		<div class="cont">
			<div class="cont-left">
				<div class="BasicInformation">
					<div class="title">
						基本信息
					</div>
					<div class="info">
						<el-row :gutter="10">
							<el-col :span="12" v-if="false">
								<el-form-item label="工 单 I D ：" prop="fOrgCategory">
									<el-input disabled v-model="from.JBinfT.fMoId"/>
								</el-form-item>
							</el-col>
							<el-col :span="24">
								<el-form-item label="工单编号：" prop="fOrgCategory">
									<el-input disabled v-model="from.JBinfT.fMocCode" />
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="产品编号：" prop="fOrgCategory">
									<el-input disabled v-model="from.JBinfT.fInvCode" />
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="预计产量：" prop="fOrgCategory">
									<el-input disabled v-model="from.JBinfT.fQty"/>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="产品品名：" prop="fOrgCategory">
									<el-input disabled v-model="from.JBinfT.fInvName"/>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="产品规格：" prop="fOrgCategory">
									<el-input disabled v-model="from.JBinfT.fInvStd"/>
								</el-form-item>
							</el-col>
							<el-col :span="24">
								<el-form-item label="规格描述：" prop="fOrgCategory">
									<el-input disabled v-model="from.JBinfT.fInvRemark"/>
								</el-form-item>
							</el-col>
							<hr style="width: 100%;margin-bottom: 1rem;">
							<el-col :span="20">
								<el-form-item label="产品条码：" prop="fOrgCategory">
									<el-input disabled v-model="from.JBinfB.barCode"/>
								</el-form-item>
							</el-col>
							<el-col :span="4">
								<el-button type="danger" @click="clearItem(2)">清空</el-button>
							</el-col>
							<el-col :span="12">
								<el-form-item label=" 操 作 员 ：">
									<el-input disabled v-model="from.JBinfB.userCode"/>
								</el-form-item>
							</el-col>
							<el-col :span="8">
								<el-form-item>
									<el-input disabled v-model="from.JBinfB.userName"/>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="报工工序：">
									<el-input disabled v-model="from.JBinfB.wpCode"/>
								</el-form-item>
							</el-col>
							<el-col :span="8">
								<el-form-item>
									<el-input disabled v-model="from.JBinfB.wpName"/>
								</el-form-item>
							</el-col>
							<el-col :span="4">
								<el-button type="danger" @click="clearItem(0)">清空</el-button>
							</el-col>
							<el-col :span='4'>
								<el-button type="danger" @click="clearItem(1)">清空</el-button>
							</el-col>
						</el-row>
					</div>
				</div>
				<div class="ApplicationForWork">
					<div class="title">
						当日报工情况
					</div>
					<div class="info">
						<el-row :gutter="10">
							<el-col :span="24">
								<el-form-item label="日期：" prop="fOrgCategory">
								  <el-date-picker
									type="date"
									v-model="from.nowBGinf.now"
								  />
								</el-form-item>
							</el-col>
							<el-col :span="12">
								工序
							</el-col>
							<el-col :span="12">
								扫描台数
							</el-col>
							<el-col :span="12">
								<el-form-item prop="fOrgCategory">
									<el-input disabled v-model="from.nowBGinf.scanPro"/>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item prop="fOrgCategory">
									<el-input disabled v-model="from.nowBGinf.proScan.scanNum"/>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								完工台数
							</el-col>
							<el-col :span="12">
								扫描物料
							</el-col>
							<el-col :span="12">
								<el-form-item prop="fOrgCategory">
									<el-input disabled v-model="from.nowBGinf.proScan.scanCompleteNum"/>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item prop="fOrgCategory">
									<el-input disabled v-model="from.nowBGinf.proScan.scanInvNum"/>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								操作员
							</el-col>
							<el-col :span="12">
								扫描台数
							</el-col>
							<el-col :span="12">
								<el-form-item prop="fOrgCategory">
									<el-input disabled v-model="from.nowBGinf.operator"/>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item prop="fOrgCategory">
									<el-input disabled v-model="from.nowBGinf.operateScan.scanNum"/>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								完工台数
							</el-col>
							<el-col :span="12">
								扫描物料
							</el-col>
							<el-col :span="12">
								<el-form-item prop="fOrgCategory">
									<el-input disabled v-model="from.nowBGinf.operateScan.scanCompleteNum"/>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item prop="fOrgCategory">
									<el-input disabled v-model="from.nowBGinf.operateScan.scanInvNum"/>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="工作站：" prop="fOrgCategory">
									<el-input disabled />
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-button type="danger" @click="clearAllConfirm" plain>初始化数据</el-button>
							</el-col>
						</el-row>
						<div class="listShow" v-if="publicData.listShow.list.length>0">
						  <el-tooltip
							class="box-item"
							effect="light"
							:content="publicData.listShow.head"
							placement="top-start"
						  >
							<div class="top">{{publicData.listShow.head}}</div>
						  </el-tooltip>
							<div class="bot">
								<ul>
								  <el-tooltip v-for="i,j in publicData.listShow.list"
									class="box-item"
									effect="dark"
									:content="i"
									placement="top-start"
								  >
									<li>{{j+1}}、{{i}}</li>
								  </el-tooltip>
								</ul>
							</div>
						</div>
					</div>
				</div>
				<div class="ScanningItems">
					<div class="title">
						扫描品号
					</div>
					<div class="info">
						<el-row :gutter="10">
							<el-col :span="24">
								  <el-table :data="tableData.SM" border style="width: 100%">
									<el-table-column :show-overflow-tooltip="true" prop="fInvBarCode" label="物料条码"/>
									<el-table-column :show-overflow-tooltip="true" prop="fBarCode" label="物料编号" />
									<el-table-column :show-overflow-tooltip="true" prop="fInvCode" label="品号" />
									<el-table-column :show-overflow-tooltip="true" prop="fMakeTime" label="制作时间" />
									
									<!-- <el-table-column :show-overflow-tooltip="true" prop="fOperator" label="操作员" /> -->
									<!-- <el-table-column :show-overflow-tooltip="true" prop="fProName" label="工序名称" /> -->
									<!-- <el-table-column :show-overflow-tooltip="true" prop="fProState" label="状态" /> -->
									
									<el-table-column :show-overflow-tooltip="true" prop="fScaPro" label="工序编号" />
									<el-table-column fixed="right" align="center" label="操作" width="100" >
										<template #default="scope">
												<el-button type="danger" @click="delSM(scope)">
													删除
												</el-button>
										</template>
									</el-table-column>
								  </el-table>
							</el-col>
						</el-row>
					</div>
				</div>
			</div>
			<div class="cont-rit">
				<div class="ScanningInf">
					<div class="title">
						扫描信息
					</div>
					<div class="info">
						<el-row :gutter="10">
							<el-col :span="24">
								<el-form-item>
								  <el-input :class="(SMinfShow.type!=-1)?'textarsu':'textar'"  type="textarea" disabled :placeholder="SMinfShow.text" />
								</el-form-item>
							</el-col>
							<el-col :span="24">
								<el-form-item label="扫描信息：" prop="fOrgName">
								  <el-input
								  ref="inputRef"
								  :autofocus="true" type="text" v-model.trim="from.smNum"
									@keyup.enter="cx"
									@click="selectInput"
								  />
								</el-form-item>
							</el-col>
						</el-row>
					</div>
				</div>
				<div class="Progress">
					<div class="title">
						<div class="text">
							物料扫描
						</div>
						<div class="fun">
							<img src="../../../assets/img/sc.png" alt="">
							<img src="../../../assets/img/sc.png" alt="">
						</div>
					</div>
					<div class="info">
						<el-row :gutter="10">
							<el-col :span="24">
								<div class="table-head-botton">
									<button @click="publicData.pageTab=0">明细</button>
									<button @click="publicData.pageTab=1">历史报工</button>
								</div>
								  <el-table :data="tableData.JG" border style="width: 100%" v-show="publicData.pageTab==0">
									<el-table-column align="center" :show-overflow-tooltip="true" prop="fSort" label="序号" />
									<el-table-column align="center" :show-overflow-tooltip="true" prop="fRequireQty" label="需扫描数" />
									<el-table-column align="center" :show-overflow-tooltip="true" prop="fAlreadyQty" label="已扫描数" />
									<el-table-column width="200" align="center" :show-overflow-tooltip="true" prop="fInvName" label="存货名称" />
									<el-table-column align="center" width="180" :show-overflow-tooltip="true" prop="fInvStd" label="规格型号" />
									<!-- <el-table-column align="center" :show-overflow-tooltip="true" prop="fProName" label="工序名称" /> -->
									<!-- <el-table-column align="center" :show-overflow-tooltip="true" prop="fScaPro" label="工序编号" /> -->
									<el-table-column align="center" :show-overflow-tooltip="true" prop="fBarCode" label="产品条码" />
									<el-table-column align="center" :show-overflow-tooltip="true" prop="fInvCode" label="存货编码" />
									<el-table-column fixed="right" align="center" label="操作" width="120" >
										<template #default="scope">
												<el-button :type="(scope.$index==publicData.nowSm)?'primary':''"  @click="select(scope.row,scope.$index)">
													选择
												</el-button>
										</template>
									</el-table-column>
								  </el-table>
								  <div class="hisList"  v-show="publicData.pageTab==1">
									<div class="ti">最近3条报工记录</div>
									<div class="lists">
										<div class="li" v-for="i,j in publicData.listShow.list">
										<span>【{{j+1}}】</span>{{ i }}
										</div>
									</div>
								  </div>
							</el-col>
						</el-row>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div class="footName">
<!-- 		<el-row :gutter="10">
			<el-col :span="1.5">
				录入人：
			</el-col>
			<el-col :span="2">
				<el-form-item>
					<el-input disabled/>
				</el-form-item>
			</el-col>
			<el-col :span="2">
				<el-form-item>
					<el-input disabled/>
				</el-form-item>
			</el-col>
		</el-row> -->
	</div>
</template>

<script setup>
	import { onMounted,getCurrentInstance,ref, reactive,watch,nextTick } from 'vue';
	import ajax from '../../../../public/JavaScript/api/ajax.js'
	import { ElMessage,ElMessageBox } from 'element-plus';
	let tableData=reactive({
		SM:[],
		JG:[]
	})
	let publicData=reactive({
		nowSm:0,
		nowData:{},
		isB:false,
		listShow:{
			head:'',
			list:[]
		},
		pageTab:0
	})
	let from=reactive({
		JBinfT:{
			fInvCode:'',
			fInvName:'',
			fInvRemark:'',
			fInvStd:'',
			fMoDId:'',
			fMoId:'',
			fMocCode:'',
			fProRemark:"",
			fQty:'',
			fcbSysBarCode:'',
			num:''
		},
		JBinfB:{
			barCode:'',
			invCode:'',
			scan:'',
			userCode:'',
			userName:'',
			wpCode:'',
			wpName:''
		},
		nowBGinf:{
			"now": new Date(),
			"operateScan": {
				"scanCompleteNum": 0,
				"scanInvNum": 0,
				"scanNum": 0
			},
			"operator": "",
			"proScan": {
				"scanCompleteNum": 0,
				"scanInvNum": 0,
				"scanNum": 0
			},
			"scanPro": ""
		},
		smNum:'',
		hisSm:''
	})
	let SMinfShow=reactive({
		type:0,
		text:'我是今日报工示例文字……',
		hisReport:'暂无信息……'
	})
	let inputRef=ref(null)
	function selectInput(){
		inputRef.value.select()
	}
	/* 清除部分扫描信息 */
	function clearItem(type){
		publicData.isB=false
		switch(type){
			case 0:
				from.JBinfB.wpCode=''
				from.JBinfB.wpName=''
				from.nowBGinf.scanPro=''
				clearObj(from.nowBGinf.proScan)
				break;
			case 1:
				from.JBinfB.userCode=''
				from.JBinfB.userName=''
				from.nowBGinf.operator=''
				clearObj(from.nowBGinf.operateScan)
				break;
			case 2:
				ElMessageBox.confirm(
				  '当前未报工,是否清空产品信息?',
				  '警告',
				  {
				    confirmButtonText: '是',
				    cancelButtonText: '否',
				    type: 'error',
				  }
				)
				  .then(() => {
					from.JBinfB.barCode=''
					clearObj(from.JBinfT)
				    ElMessage({
				      type: 'success',
				      message: '清除成功!',
				    })
				  })
				break;
			case 3:
				break;
			default:
				break;
		}
	}
	/* 删除扫描品号 */
	function delSM(ev){
		ElMessageBox.confirm(
		  '是否对该产品进行删除?',
		  '警告',
		  {
		    confirmButtonText: '是',
		    cancelButtonText: '否',
		    type: 'error',
		  }
		)
		  .then(() => {
			ajax.post('/mrpc/dinv',{
				body:{
				  "barCode":ev.row.fBarCode,
				  "invCode": ev.row.fInvCode,
				  "invFid": ev.row.fId,
				  "scan": ev.row.fInvBarCode,
				  "userCode": from.JBinfB.userCode,
				  "userName": from.JBinfB.userName,
				  "wpCode": from.JBinfB.wpCode,
				  "wpName": from.JBinfB.userName
				}
			},res=>{
				console.log(res)
				if(res.code==200){
					ElMessage.success('删除成功')
					tableData.SM=res.data.data.alreadyList
					tableData.JG=res.data.data.withoutVoList
					publicData.nowData=res.data.data.withoutVoList[0]
					publicData.nowSm=0
					nowBGinf()
				}else{
					ElMessage.error(res.msg)
				}
			})
		  })
	}
	function cx(){
		console.log(from.smNum)
		selectData()
	}
	function selectData(fn){
		if(from.smNum=='00' || from.smNum=='01'){
			if(from.JBinfB.userCode.length>0 && from.JBinfB.wpCode.length>0 && from.JBinfB.barCode.length>0){
				ajax.post('/mrpc/submit',{
					body:{
						"barCode": from.JBinfB.barCode,
						"invCode": "",
						"scan": from.smNum,
						"userCode": from.JBinfB.userCode,
						"userName": from.JBinfB.userName,
						"wpCode": from.JBinfB.wpCode,
						"wpName": from.JBinfB.wpName
					}
				},res=>{
					console.log(res)
					if(res.code==200){
						SMinfShow.text=res.data.scanMsg
						SMinfShow.type=res.data.scanCode
						if(res.data.scanCode!=-1){
							tableData.JG=[]
							tableData.SM=[]
							publicData.isB=false
							from.JBinfB.barCode=''
							clearObj(from.JBinfT)
						}else{
							ElMessageBox.confirm(
							  (res.data.scanMsg),
							  '警告',
							  {
							    confirmButtonText: '是',
							    cancelButtonText: '否',
							    type: 'error',
							  }
							)
							  .then(() => {
								ajax.post('/mrpc/sureSubmit',{
									body:{
										"barCode": from.JBinfB.barCode,
										"invCode": "",
										"scan": from.smNum,
										"userCode": from.JBinfB.userCode,
										"userName": from.JBinfB.userName,
										"wpCode": from.JBinfB.wpCode,
										"wpName": from.JBinfB.wpName
									}
								},resd=>{
									SMinfShow.text=resd.data.scanMsg
									SMinfShow.type=resd.data.scanCode
									ElMessage(resd.text)
									tableData.JG=[]
									tableData.SM=[]
									publicData.isB=false
									from.JBinfB.barCode=''
									clearObj(from.JBinfT)
								})
							  })
						}
					}else{
						audioErr()
					}
					nowBGinf()
					inputRef.value.select()
				},err=>{
					console.log(err)
					inputRef.value.select()
				})
			}else{
				ElMessage.error('请保证基础信息完整')
			}
		}else{
			ajax.post('/mrpc/sinfo',{
				body:{
				  "barCode": from.JBinfB.barCode,
				  "invCode": from.JBinfB.invCode,
				  "scan": from.smNum,
				  "userCode": from.JBinfB.userCode,
				  "userName": from.JBinfB.userName,
				  "wpCode": from.JBinfB.wpCode,
				  "wpName": from.JBinfB.wpName
				}
			},res=>{
				if(res.code==200){
					if(res.data.scanCode==1){
						from.JBinfB.barCode=res.data.data?.barCode || from.JBinfB.barCode
						from.JBinfT=res.data.data?.mocoRdersDisplayVo || from.JBinfT
						SMinfShow.text=res.data.scanMsg || '啥也没有'
						SMinfShow.type=res.data.scanCode || 0
					}
					if(res.data.scanCode==3){
						from.JBinfB.userName=res.data.data.name || from.JBinfB.userName
						from.JBinfB.userCode=res.data.data.code || from.JBinfB.userCode
						SMinfShow.text=res.data.scanMsg || '啥也没有'
						SMinfShow.type=res.data.scanCode || 0
					}else if(res.data.scanCode==2){
						from.JBinfB.wpCode=res.data.data.code || from.JBinfB.wpCode
						from.JBinfB.wpName=res.data.data.name || from.JBinfB.wpName
						SMinfShow.text=res.data.scanMsg || '啥也没有'
						SMinfShow.type=res.data.scanCode || 0
					}
					if(res.data.scanCode==-1){
						ajax.post('/mrpc/sinv',{
							body:{
								"barCode": from.JBinfB.barCode,
								"invCode": publicData.nowData.fInvCode,
								"scan": from.smNum,
								"userCode": from.JBinfB.userCode,
								"userName": from.JBinfB.userName,
								"wpCode": from.JBinfB.wpCode,
								"wpName": from.JBinfB.wpName
							}
						},res=>{
							console.log(res)
							if(res.code==200){
								SMinfShow.text=res.data.scanMsg
								SMinfShow.type=res.data.scanCode
								tableData.SM=res.data.data.alreadyList
								tableData.JG=res.data.data.withoutVoList
								publicData.nowSm=0
								publicData.nowData=res.data.data?.withoutVoList[0] || {}
								inputRef.value.select()
								nowBGinf()
							}else{
								ElMessage.error(res.msg)
								SMinfShow.text=err.msg
								SMinfShow.type=-1
								inputRef.value.select()
							}
						},err=>{
							console.log(err)
							inputRef.value.select()
						})
					}
					nowBGinf()
					cxSm()
					inputRef.value.select()
				}else{
					audioErr()
					ElMessage.error(res.msg)
					SMinfShow.text=res.msg
					SMinfShow.type=0
				}
			},err=>{
				console.log(err)
			})
		}

		// if(!publicData.isB){
		// 	ajax.post('/mrpc/sinfo',{
		// 		body:{
		// 		  "barCode": from.JBinfB.barCode,
		// 		  "invCode": from.JBinfB.invCode,
		// 		  "scan": from.smNum,
		// 		  "userCode": from.JBinfB.userCode,
		// 		  "userName": from.JBinfB.userName,
		// 		  "wpCode": from.JBinfB.wpCode,
		// 		  "wpName": from.JBinfB.wpName
		// 		}
		// 	},res=>{
		// 		console.log(res)
		// 		if(res.code==200){
		// 			SMinfShow.text=res.data.scanMsg || '啥也没有'
		// 			SMinfShow.type=res.data.scanCode || 0
		// 			if(res.data.scanCode==1){
		// 				from.JBinfB.barCode=res.data.data?.barCode || from.JBinfB.barCode
		// 				from.JBinfT=res.data.data?.mocoRdersDisplayVo || from.JBinfT
		// 			}
		// 			if(res.data.scanCode==3){
		// 				from.JBinfB.userName=res.data.data.name || from.JBinfB.userName
		// 				from.JBinfB.userCode=res.data.data.code || from.JBinfB.userCode
		// 			}else if(res.data.scanCode==2){
		// 				from.JBinfB.wpCode=res.data.data.code || from.JBinfB.wpCode
		// 				from.JBinfB.wpName=res.data.data.name || from.JBinfB.wpName
		// 			}
		// 			if(from.JBinfB.barCode && from.JBinfB.userCode && from.JBinfB.wpCode){
		// 				publicData.isB=true
		// 			}
		// 			nowBGinf()
		// 			cxSm()
		// 			inputRef.value.select()
		// 		}else{
		// 			audioErr()
		// 			ElMessage.error(res.msg)
		// 			SMinfShow.text=res.msg
		// 			SMinfShow.type=0
		// 		}
		// 	},err=>{
		// 		console.log(err)
		// 	})
		// }else{
		// 	Report()
		// }

	}
	function select(data,index){
		console.log(data,index)
		publicData.nowSm=index
		publicData.nowData=data
	}
	function cxSm(){
		if(from.JBinfB.barCode && from.JBinfB.wpCode){
			ajax.post('/mrpc/spro',{
				body:{
					"barCode": from.JBinfB.barCode,
					"invCode": from.JBinfB.invCode,
					"scan": "",
					"userCode": from.JBinfB.userCode,
					"userName": from.JBinfB.userName,
					"wpCode": from.JBinfB.wpCode,
					"wpName": from.JBinfB.wpName
				}
			},res=>{
				console.log(res)
				if(res.code==200){
					tableData.SM=res.data.alreadyList
					tableData.JG=res.data.withoutVoList
					publicData.nowSm=0
					publicData.nowData=res.data?.withoutVoList[0] || {}
				}else{
					ElMessage.error(res.msg)
					SMinfShow.text=res.msg
					SMinfShow.type=-1
				}
			},err=>{
				SMinfShow.text=err.msg
				SMinfShow.type=-1
			})
		}
	}
	function nowBGinf(){
		if(from.JBinfB.wpCode || from.JBinfB.userCode){
			ajax.post('/mrpc/stotal',{
				body:{
					"barCode": from.JBinfB.barCode,
					"invCode": from.JBinfB.invCode,
					"scan": "",
					"userCode": from.JBinfB.userCode,
					"userName": from.JBinfB.userName,
					"wpCode": from.JBinfB.wpCode,
					"wpName": from.JBinfB.wpName
				}
			},res=>{
				console.log(res)
				from.nowBGinf.now=res.data.now
				if(res.data.operateScan){
					from.nowBGinf.operateScan=res.data.operateScan
					from.nowBGinf.operator=res.data.operator
				}
				if(res.data.proScan){
					from.nowBGinf.proScan=res.data.proScan
					from.nowBGinf.scanPro=res.data.scanPro
				}
			},err=>{
				console.log(err)
			})
		}
	}
	function Report(){
		if(from.JBinfB.barCode && from.JBinfB.userCode && from.JBinfB.wpCode){
			if(from.smNum=='00' || from.smNum=='01'){
				ajax.post('/mrpc/submit',{
					body:{
						"barCode": from.JBinfB.barCode,
						"invCode": "",
						"scan": from.smNum,
						"userCode": from.JBinfB.userCode,
						"userName": from.JBinfB.userName,
						"wpCode": from.JBinfB.wpCode,
						"wpName": from.JBinfB.wpName
					}
				},res=>{
					console.log(res)
					if(res.code==200){
						SMinfShow.text=res.data.scanMsg
						SMinfShow.type=res.data.scanCode
						if(res.data.scanCode!=-1){
							tableData.JG=[]
							tableData.SM=[]
							publicData.isB=false
							from.JBinfB.barCode=''
							clearObj(from.JBinfT)
						}else{
							ElMessageBox.confirm(
							  (res.data.scanMsg),
							  '警告',
							  {
							    confirmButtonText: '是',
							    cancelButtonText: '否',
							    type: 'error',
							  }
							)
							  .then(() => {
								ajax.post('/mrpc/sureSubmit',{
									body:{
										"barCode": from.JBinfB.barCode,
										"invCode": "",
										"scan": from.smNum,
										"userCode": from.JBinfB.userCode,
										"userName": from.JBinfB.userName,
										"wpCode": from.JBinfB.wpCode,
										"wpName": from.JBinfB.wpName
									}
								},resd=>{
									SMinfShow.text=resd.data.scanMsg
									SMinfShow.type=resd.data.scanCode
									ElMessage(resd.text)
									tableData.JG=[]
									tableData.SM=[]
									publicData.isB=false
									from.JBinfB.barCode=''
									clearObj(from.JBinfT)
								})
							  })
						}
					}else{
						audioErr()
					}
					inputRef.value.select()
				},err=>{
					console.log(err)
					inputRef.value.select()
				})
			}else{
				if(tableData.JG.length>0){

				}else{
					ajax.post('/mrpc/sinfo',{
						body:{
						  "barCode": from.JBinfB.barCode,
						  "invCode": from.JBinfB.invCode,
						  "scan": from.smNum,
						  "userCode": from.JBinfB.userCode,
						  "userName": from.JBinfB.userName,
						  "wpCode": from.JBinfB.wpCode,
						  "wpName": from.JBinfB.wpName
						}
					},res=>{
						console.log(res)
						if(res.code==200){
							SMinfShow.text=res.data.scanMsg || '啥也没有'
							SMinfShow.type=res.data.scanCode || 0
							from.JBinfB.barCode=res.data.data?.barCode || from.JBinfB.barCode
							from.JBinfT=res.data.data?.mocoRdersDisplayVo || from.JBinfT
							if(res.data.scanCode==3){
								from.JBinfB.userName=res.data.data.name || from.JBinfB.userName
								from.JBinfB.userCode=res.data.data.code || from.JBinfB.userCode
							}else if(res.data.scanCode==2){
								from.JBinfB.wpCode=res.data.data.code || from.JBinfB.wpCode
								from.JBinfB.wpName=res.data.data.name || from.JBinfB.wpName
							}
							if(from.JBinfB.barCode && from.JBinfB.userCode && from.JBinfB.wpCode){
								publicData.isB=true
							}
							cxSm()
							nowBGinf()
							inputRef.value.select()
						}else{
							audioErr()
							ElMessage.error(res.msg)
							SMinfShow.text=res.msg
							SMinfShow.type=0
						}
					},err=>{
						console.log(err)
					})
				}
			}
			cxSm()
			nowBGinf()
		}
	}
	function clearAll(){
		tableData.SM=[]
		tableData.JG=[]
		publicData.nowData={}
		publicData.nowSm=0
		publicData.isB=false
		clearObj(from.JBinfT)
		clearObj(from.JBinfB)
		from.nowBGinf.now=new Date();
		from.nowBGinf.operator=''
		from.nowBGinf.scanPro=''
		clearObj(from.nowBGinf.operateScan)
		clearObj(from.nowBGinf.proScan)
		from.smNum=''
		from.hisSm=''
	}
	function clearAllConfirm(){
		ElMessageBox.confirm(
		  '当前未报工,是否重置扫描信息?',
		  '警告',
		  {
		    confirmButtonText: '是',
		    cancelButtonText: '否',
		    type: 'error',
		  }
		)
		  .then(() => {
			  clearAll()
		    ElMessage({
		      type: 'success',
		      message: '重置成功!',
		    })
		  })
	}
	function clearObj(obj){
		for(let i in obj){
			obj[i]=''
		}
	}
	let refd=''
	onMounted(()=>{
		refd=getCurrentInstance()
	})
	function start(ev){
		refd.ctx.$refs.mar.start()
	}
	function stop(ev){
		refd.ctx.$refs.mar.stop()
	}
	function audioSuc(){
		// refd.ctx.$refs.audioT.play();//play()
	}
	function audioErr(){
		// refd.ctx.$refs.audio.play();//play()
	}
	watch(()=>from.JBinfB,()=>{
		if(from.JBinfB.userCode && from.JBinfB.wpCode){
			/* 查询历史三条报工 */
			let str=''
			ajax.post('/mrpc/slt',{
				body:{
					"userCode": from.JBinfB.userCode,
					"userName": from.JBinfB.userName,
					"wpCode": from.JBinfB.wpCode,
					"wpName": from.JBinfB.wpName
				}
			},res=>{
				if(res.code==200){
					publicData.listShow.head=res.data?.head || ''
					publicData.listShow.list=res.data.body || []
				}else{
					// ElMessage.error(res.msg)
				}
			})
		}
	},{deep:true})
</script>

<style lang="less" scoped>
	@import url("./ProcessManagement.less");
</style>